package leetcode.mockInterview;

/**
 * @author jiangwz
 * @create 2019/11/6.
 */
public class TitleToNumber {

    public int titleToNumber(String s) {
        //A -> 65 Z->90  a->97 z->122
        // AC    C = 26
        int length = s.length();
        int total = 0;
        for (int i = 0; i < length; i++) {
            char c = s.charAt(i);
            total+=(Integer.valueOf(c)-64) * Math.pow(26, (length - i - 1));
        }
        return total;
    }

    public static void main(String[] args){
        char c = 'a';
        System.out.println((int) c);
//        System.out.println(Integer.valueOf(c));
//        System.out.println(Math.pow(2, 3));
        System.out.println(new TitleToNumber().titleToNumber("ZY"));
    }
}
